package com.jchy.renderit.core;
  
public class Point
{
    public double x, y, z;

    public Point()
    {
        x=0; y=0; z=0;
    }

    Point(int inx, int iny, int inz)
    {
        x=inx; y=iny; z=inz;
    }

    public Point(double inx, double iny, double inz)
    {
        x=inx; y=iny; z=inz;
    }
 
    public Point copy()
    {
        Point result=new Point(x,y,z);
        return result;
    }

    public void setPosition(double inx, double iny, double inz)
    {
        x=inx; y=iny; z=inz;   
    }

    // toDir: calculates direction vector toDir = x2 - x1.
    // this is x1, parameter is x2
    public Dir toDir(Point x2)
    {  
        Dir result = new Dir(x2.x-x,x2.y-y,x2.z-z);
        return result;
    }

    public double Dist(Point x2)
    {
        Dir avector = toDir(x2);
        return avector.length();
    }

    public static double cosAngle(Point a, Point b, Point c)
    {
        Dir ba=b.toDir(a);
        Dir bc=b.toDir(c);
        ba.normalize();
        bc.normalize();
        return Dir.dot(ba,bc);
    }

    public String toString()
    {
        return ("[" + x + ", " + y + ", " + z + "]");
    }
}

